<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>用户登录页面</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Free HTML5 Template by FreeHTML5.co" />
<meta name="keywords"
	content="free html5, free template, free bootstrap, html5, css3, mobile first, responsive" />

<link rel="stylesheet"
	href="${pageContext.request.contextPath}/layui/css/layui.css">

<!-- Facebook and Twitter integration -->
<meta property="og:title" content="" />
<meta property="og:image" content="" />
<meta property="og:url" content="" />
<meta property="og:site_name" content="" />
<meta property="og:description" content="" />
<meta name="twitter:title" content="" />
<meta name="twitter:image" content="" />
<meta name="twitter:url" content="" />
<meta name="twitter:card" content="" />

<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<link rel="shortcut icon" href="favicon.ico">

<link
	href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,300'
	rel='stylesheet' type='text/css'>

<link rel="stylesheet"
	href="${pageContext.request.contextPath}/login/css-login/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/login/css-login/animate.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/login/css-login/style.css">

<!-- <script src="http://code.jquery.com/jquery-latest.js"></script>
 -->
<style type="text/css">
body {
	background-image:
		url(${pageContext.request.contextPath}/login/images-login/geometry2.png);
}
</style>
<script type="text/javascript">
	function refresh() {
		//IE存在缓存,需要new Date()实现更换路径的作用  
		document.getElementById("image").src = "${pageContext.request.contextPath}/image.jsp?"
				+ new Date();
	}
</script>

</head>
<body>
	<%-- <%
	//获取用户信息
		String utel = (String) session.getAttribute("utel");
	if(utel==null){
		//保存错误信息到request中，然后转发到login/index,提醒登录
		request.setAttribute("message", "请登录");
		//转发到登录界面
		request.getRequestDispatcher("/jsp/login/index.jsp").forward(request, response);
		
	}
	%> --%>

	<div class="container">
		<div class="row">
			<div class="col-md-12 text-center">
				<ul class="menu">
					<li class="active"><a href="${pageContext.request.contextPath}/adminapi/dologin">我是用户</a></li>
					<li><a href="${pageContext.request.contextPath}/index-login2">我是商家</a></li>
					<li><a href="${pageContext.request.contextPath}/index-login3">我是管理员</a></li>
				</ul>
			</div>
		</div>

		<div class="row">
			<div class="col-md-4 col-md-offset-4">


				<!-- Start Sign In Form -->
				<!-- onsubmit="return false" -->
				<form id=form1 class="fh5co-form animate-box" action="login"
					method="post">
					<h2>欢迎登录</h2>
					<div class="form-group">

						<input type="text" class="form-control" name="utel" id="u_tel"
							placeholder="电话号码" autocomplete="off">
					</div>
					<div class="form-group">

						<input type="password" class="form-control" name="upwd" id="u_pwd"
							placeholder="密码" autocomplete="off">
					</div>
					<div class="form-group">
						<input type="checkbox" id="remember"> 记住我</label>
					</div>
					<div class="form-group">
						<p>
							还没有账号吗? <a href="doregist">立刻注册</a>
						</p>
					</div>
					<div class="form-group">
						验证码：<input type="text" name="code" maxlength="4"> <img
							id="image" border="0" onclick="refresh()"
							src="${pageContext.request.contextPath}/image.jsp" title="点击更换图片">
					</div>
					<div class="form-group">
						<input type="button" value="登录" onclick="login()"
							class="btn btn-primary">
					</div>
				</form>



				<!-- END Sign In Form -->

			</div>
		</div>

	</div>
	<script src="${pageContext.request.contextPath}/layui/layui.all.js"></script>

	<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">
		
	</script>
	<script type="text/javascript">
		function login() {
			var utel = $("#u_tel").val();
			var upwd = $("#u_pwd").val();
			$.ajax({
				type : "post",//提交方法
				dataType : "json",
				url : "login",
				data : $("#form1").serialize(),
				success : function(data) {

					console.log(data);

					if (data.msg == "success") {

						layui.use('layer', function() {
							var layer = layui.layer;
							layer.msg('登陆成功');

						});
						setTimeout("location.href = 'douser';", 1000);
					} else {
						layui.use('layer', function() {
							var layer = layui.layer;
							layer.msg('登陆失败');
						});
						setTimeout("location.href='dologin';", 1000);
					}
				},
				error : function() {

					if (utel == "" || upwd == "") {

						layui.use('layer', function() {
							var layer = layui.layer;

							layer.msg('电话号码密码不能为空');
						});
					}
					setTimeout("location.href='dologin';", 1000);
				}

			});
		}
	</script>


	<!-- jQuery -->
	<script
		src="${pageContext.request.contextPath}/login/js-login/jquery.min.js"></script>
	<!-- Bootstrap -->
	<script
		src="${pageContext.request.contextPath}/login/js-login/bootstrap.min.js"></script>
	<!-- Placeholder -->
	<script
		src="${pageContext.request.contextPath}/login/js-login/jquery.placeholder.min.js"></script>
	<!-- Waypoints -->
	<script
		src="${pageContext.request.contextPath}/login/js-login/jquery.waypoints.min.js"></script>
	<!-- Main JS -->
	<script src="${pageContext.request.contextPath}/login/js-login/main.js"></script>


</body>
</html>